<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>绿能充 - 系统设置</title>
    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <style>
        :root {
            --primary-color: #00a896;
            --secondary-color: #02c39a;
            --dark-color: #05668d;
            --light-color: #f0f3bd;
            --accent-color: #028090;
            --text-dark: #333;
            --text-light: #f8f9fa;
            --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Noto Sans SC', sans-serif;
            color: var(--text-dark);
            background-color: #f9f9f9;
            min-height: 100vh;
            display: flex;
        }

        /* 侧边栏样式 - 保持不变 */
        .sidebar {
            width: 250px;
            background: linear-gradient(135deg, var(--dark-color) 0%, var(--primary-color) 100%);
            color: white;
            padding: 20px 0;
            height: 100vh;
            position: fixed;
            box-shadow: var(--shadow);
            z-index: 100;
        }

        .sidebar-header {
            padding: 0 20px 20px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            margin-bottom: 20px;
        }

        .sidebar-header .logo {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
        }

        .sidebar-header .logo-icon {
            width: 40px;
            height: 40px;
            background-color: rgba(255, 255, 255, 0.2);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 10px;
            font-size: 18px;
            color: var(--light-color);
        }

        .sidebar-header h3 {
            font-size: 1.2rem;
            font-weight: 500;
            margin: 0;
        }

        .sidebar-header p {
            font-size: 0.8rem;
            opacity: 0.8;
            margin: 0;
        }

        .nav-menu {
            list-style: none;
            padding: 0 15px;
        }

        .nav-item {
            margin-bottom: 5px;
        }

        .nav-link {
            display: flex;
            align-items: center;
            padding: 12px 15px;
            color: rgba(255, 255, 255, 0.8);
            text-decoration: none;
            border-radius: 8px;
            transition: var(--transition);
        }

        .nav-link:hover, .nav-link.active {
            background-color: rgba(255, 255, 255, 0.1);
            color: white;
        }

        .nav-link i {
            margin-right: 10px;
            width: 20px;
            text-align: center;
            font-size: 16px;
        }

        .nav-link .badge {
            margin-left: auto;
            background-color: var(--light-color);
            color: var(--dark-color);
            font-size: 0.7rem;
            padding: 3px 6px;
            border-radius: 10px;
        }

        .user-profile {
            position: absolute;
            bottom: 20px;
            left: 0;
            width: 100%;
            padding: 0 20px;
        }

        .user-info {
            display: flex;
            align-items: center;
            padding: 10px;
            background-color: rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            cursor: pointer;
            transition: var(--transition);
        }

        .user-info:hover {
            background-color: rgba(255, 255, 255, 0.2);
        }

        .user-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background-color: rgba(255, 255, 255, 0.2);
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 10px;
            font-size: 14px;
        }

        .user-name {
            font-size: 0.9rem;
            font-weight: 500;
            margin-bottom: 2px;
        }

        .user-role {
            font-size: 0.7rem;
            opacity: 0.8;
        }

        /* 主内容区样式 */
        .main-content {
            flex: 1;
            margin-left: 250px;
            padding: 30px;
        }

        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 30px;
        }

        .page-title h1 {
            font-size: 1.8rem;
            font-weight: 600;
            color: var(--dark-color);
            margin-bottom: 5px;
        }

        .page-title p {
            color: #777;
            font-size: 0.9rem;
            margin: 0;
        }

        /* 系统设置页面特定样式 */
        .settings-container {
            display: grid;
            grid-template-columns: 1fr;
            gap: 20px;
        }

        .settings-card {
            background-color: white;
            border-radius: 12px;
            box-shadow: var(--shadow);
            padding: 25px;
            margin-bottom: 20px;
            transition: var(--transition);
        }

        .settings-card:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
        }

        .settings-card h3 {
            font-size: 1.2rem;
            font-weight: 600;
            color: var(--dark-color);
            margin-bottom: 20px;
            padding-bottom: 15px;
            border-bottom: 1px solid #eee;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .settings-card h3 i {
            color: var(--primary-color);
        }

        .form-group {
            margin-bottom: 20px;
        }

        .form-group label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
            color: #555;
        }

        .form-control {
            width: 100%;
            padding: 10px 15px;
            border: 1px solid #ddd;
            border-radius: 8px;
            font-size: 0.95rem;
            transition: var(--transition);
            font-family: 'Noto Sans SC', sans-serif;
        }

        .form-control:focus {
            border-color: var(--primary-color);
            outline: none;
            box-shadow: 0 0 0 3px rgba(0, 168, 150, 0.1);
        }

        .form-row {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
        }

        .form-actions {
            display: flex;
            justify-content: flex-end;
            gap: 10px;
            margin-top: 20px;
        }

        .radio-group {
            display: flex;
            gap: 20px;
            flex-wrap: wrap;
        }

        .radio-option {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .radio-option input {
            margin: 0;
        }

        .map-container {
            height: 300px;
            background-color: #f5f5f5;
            border-radius: 8px;
            margin-top: 15px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #777;
            border: 1px dashed #ddd;
        }

        .tab-container {
            margin-bottom: 20px;
        }

        .tab-buttons {
            display: flex;
            border-bottom: 1px solid #eee;
        }

        .tab-button {
            padding: 10px 20px;
            background: none;
            border: none;
            cursor: pointer;
            font-weight: 500;
            color: #777;
            position: relative;
            transition: var(--transition);
        }

        .tab-button:hover {
            color: var(--primary-color);
        }

        .tab-button.active {
            color: var(--primary-color);
        }

        .tab-button.active::after {
            content: '';
            position: absolute;
            bottom: -1px;
            left: 0;
            width: 100%;
            height: 2px;
            background-color: var(--primary-color);
        }

        .tab-content {
            display: none;
            padding-top: 20px;
            animation: fadeIn 0.3s ease;
        }

        .tab-content.active {
            display: block;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        /* 按钮样式与主页面一致 */
        .btn {
            padding: 8px 16px;
            border-radius: 8px;
            font-size: 0.9rem;
            font-weight: 500;
            border: none;
            cursor: pointer;
            transition: var(--transition);
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .btn i {
            font-size: 14px;
        }

        .btn-primary {
            background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
            color: white;
            box-shadow: 0 4px 15px rgba(0, 168, 150, 0.3);
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 20px rgba(0, 168, 150, 0.4);
        }

        .btn-outline {
            background: transparent;
            border: 1px solid #ddd;
            color: #555;
        }

        .btn-outline:hover {
            background-color: #f5f5f5;
        }

        .btn-sm {
            padding: 5px 10px;
            font-size: 0.8rem;
        }

        /* 表格样式 */
        .table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 15px;
        }

        .table th, .table td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid #eee;
        }

        .table th {
            font-weight: 500;
            color: #555;
            font-size: 0.9rem;
        }

        .table tr:hover {
            background-color: #f9f9f9;
        }

        /* 文本区域样式 */
        textarea.form-control {
            min-height: 100px;
            resize: vertical;
        }

        /* 响应式设计 */
        @media (max-width: 992px) {
            .sidebar {
                width: 70px;
                overflow: hidden;
            }

            .sidebar-header h3,
            .sidebar-header p,
            .nav-link span,
            .user-name,
            .user-role {
                display: none;
            }

            .sidebar-header {
                padding: 15px 10px;
            }

            .nav-link {
                justify-content: center;
                padding: 12px 0;
            }

            .nav-link i {
                margin-right: 0;
                font-size: 18px;
            }

            .main-content {
                margin-left: 70px;
            }
        }

        @media (max-width: 768px) {
            .form-row {
                grid-template-columns: 1fr;
            }

            .radio-group {
                flex-direction: column;
                gap: 10px;
            }

            .tab-buttons {
                overflow-x: auto;
                white-space: nowrap;
            }

            .header {
                flex-direction: column;
                align-items: flex-start;
                gap: 15px;
            }
        }

        @media (max-width: 576px) {
            .main-content {
                padding: 20px 15px;
            }
        }
    </style>
</head>
<body>
<!-- 侧边导航栏 -->
<div class="sidebar">
    <div class="sidebar-header">
        <div class="logo">
            <div class="logo-icon">
                <i class="fas fa-charging-station"></i>
            </div>
            <div>
                <h3>绿能充</h3>
                <p>管理员面板</p>
            </div>
        </div>
    </div>

    <ul class="nav-menu">
        <li class="nav-item">
            <a href="/admin/dashboard" class="nav-link">
                <i class="fas fa-tachometer-alt"></i>
                <span>仪表盘</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/admin/user/list" class="nav-link">
                <i class="fas fa-users"></i>
                <span>用户管理</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/admin/pile/list" class="nav-link">
                <i class="fas fa-charging-station"></i>
                <span>充电桩管理</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/admin/report/list" class="nav-link">
                <i class="fas fa-list-alt"></i>
                <span>充电记录</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/admin/fault/list" class="nav-link">
                <i class="fas fa-exclamation-triangle"></i>
                <span>故障报告</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/admin/settings" class="nav-link active">
                <i class="fas fa-cog"></i>
                <span>系统设置</span>
            </a>
        </li>
    </ul>

    <div class="user-profile">
        <div class="user-info">
            <div class="user-avatar">
                <i class="fas fa-user"></i>
            </div>
            <div>
                <div class="user-name">管理员</div>
                <div class="user-role">超级管理员</div>
            </div>
        </div>
    </div>
</div>

<!-- 主内容区 -->
<div class="main-content">
    <div class="header">
        <div class="page-title">
            <h1>系统设置</h1>
            <p>管理系统参数和配置</p>
        </div>
    </div>

    <div class="tab-container">
        <div class="tab-buttons">
            <button class="tab-button active" onclick="openTab(event, 'pile-settings')">
                <i class="fas fa-charging-station"></i> 充电桩设置
            </button>
            <button class="tab-button" onclick="openTab(event, 'payment-settings')">
                <i class="fas fa-money-bill-wave"></i> 支付设置
            </button>
            <button class="tab-button" onclick="openTab(event, 'system-settings')">
                <i class="fas fa-cog"></i> 系统参数
            </button>
            <button class="tab-button" onclick="openTab(event, 'user-permissions')">
                <i class="fas fa-user-shield"></i> 用户权限
            </button>
        </div>
    </div>

    <div class="settings-container">
        <!-- 充电桩设置 -->
        <div id="pile-settings" class="tab-content active">
            <div class="settings-card">
                <h3><i class="fas fa-charging-station"></i> 充电桩默认参数</h3>
                <form action="/admin/settings/pile" method="post">
                    <div class="form-row">
                        <div class="form-group">
                            <label for="defaultPrice">默认价格 (元/度)</label>
                            <input type="number" step="0.01" class="form-control" id="defaultPrice" name="defaultPrice"
                                   value="${settings.defaultPrice}" required>
                        </div>
                        <div class="form-group">
                            <label for="defaultPower">默认功率 (kW)</label>
                            <input type="number" step="0.1" class="form-control" id="defaultPower" name="defaultPower"
                                   value="${settings.defaultPower}" required>
                        </div>
                    </div>

                    <div class="form-group">
                        <label>默认充电桩类型</label>
                        <div class="radio-group">
                            <div class="radio-option">
                                <input type="radio" id="typeAC" name="defaultType" value="AC"
                                ${settings.defaultType == 'AC' ? 'checked' : ''}>
                                <label for="typeAC">交流充电桩 (AC)</label>
                            </div>
                            <div class="radio-option">
                                <input type="radio" id="typeDC" name="defaultType" value="DC"
                                ${settings.defaultType == 'DC' ? 'checked' : ''}>
                                <label for="typeDC">直流充电桩 (DC)</label>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="defaultOperator">默认运营商</label>
                        <input type="text" class="form-control" id="defaultOperator" name="defaultOperator"
                               value="${settings.defaultOperator}" required>
                    </div>

                    <div class="form-actions">
                        <button type="reset" class="btn btn-outline">
                            <i class="fas fa-undo"></i> 重置
                        </button>
                        <button type="submit" class="btn btn-primary">
                            <i class="fas fa-save"></i> 保存设置
                        </button>
                    </div>
                </form>
            </div>

            <div class="settings-card">
                <h3><i class="fas fa-map-marker-alt"></i> 充电桩位置设置</h3>
                <div class="form-group">
                    <label for="mapCenter">地图中心坐标</label>
                    <div class="form-row">
                        <div class="form-group">
                            <label for="latitude">纬度</label>
                            <input type="text" class="form-control" id="latitude" name="latitude"
                                   value="${settings.mapCenterLat}" required>
                        </div>
                        <div class="form-group">
                            <label for="longitude">经度</label>
                            <input type="text" class="form-control" id="longitude" name="longitude"
                                   value="${settings.mapCenterLng}" required>
                        </div>
                    </div>
                    <div class="map-container" id="mapPreview">
                        <i class="fas fa-map-marked-alt" style="font-size: 24px; margin-right: 10px;"></i>
                        <span>地图预览区域</span>
                    </div>
                </div>
                <div class="form-actions">
                    <button type="button" class="btn btn-primary" onclick="updateMapCenter()">
                        <i class="fas fa-sync-alt"></i> 更新地图中心
                    </button>
                </div>
            </div>
        </div>

        <!-- 支付设置 -->
        <div id="payment-settings" class="tab-content">
            <div class="settings-card">
                <h3><i class="fas fa-money-bill-wave"></i> 支付参数设置</h3>
                <form action="/admin/settings/payment" method="post">
                    <div class="form-group">
                        <label>启用支付方式</label>
                        <div class="radio-group">
                            <div class="radio-option">
                                <input type="checkbox" id="enableAlipay" name="enableAlipay"
                                ${settings.enableAlipay ? 'checked' : ''}>
                                <label for="enableAlipay"><i class="fab fa-alipay" style="color: #00a0e9;"></i> 支付宝支付</label>
                            </div>
                            <div class="radio-option">
                                <input type="checkbox" id="enableWechat" name="enableWechat"
                                ${settings.enableWechat ? 'checked' : ''}>
                                <label for="enableWechat"><i class="fab fa-weixin" style="color: #07c160;"></i> 微信支付</label>
                            </div>
                            <div class="radio-option">
                                <input type="checkbox" id="enableBalance" name="enableBalance"
                                ${settings.enableBalance ? 'checked' : ''}>
                                <label for="enableBalance"><i class="fas fa-wallet" style="color: var(--primary-color);"></i> 余额支付</label>
                            </div>
                        </div>
                    </div>

                    <div class="form-row">
                        <div class="form-group">
                            <label for="minRechargeAmount">最低充值金额 (元)</label>
                            <input type="number" step="1" min="1" class="form-control" id="minRechargeAmount"
                                   name="minRechargeAmount" value="${settings.minRechargeAmount}" required>
                        </div>
                        <div class="form-group">
                            <label for="maxRechargeAmount">最高充值金额 (元)</label>
                            <input type="number" step="1" min="1" class="form-control" id="maxRechargeAmount"
                                   name="maxRechargeAmount" value="${settings.maxRechargeAmount}" required>
                        </div>
                    </div>

                    <div class="form-actions">
                        <button type="reset" class="btn btn-outline">
                            <i class="fas fa-undo"></i> 重置
                        </button>
                        <button type="submit" class="btn btn-primary">
                            <i class="fas fa-save"></i> 保存设置
                        </button>
                    </div>
                </form>
            </div>

            <div class="settings-card">
                <h3><i class="fas fa-key"></i> 支付密钥设置</h3>
                <form action="/admin/settings/payment-keys" method="post">
                    <div class="form-group">
                        <label for="alipayAppId">支付宝AppID</label>
                        <input type="text" class="form-control" id="alipayAppId" name="alipayAppId"
                               value="${settings.alipayAppId}">
                    </div>

                    <div class="form-group">
                        <label for="alipayPublicKey">支付宝公钥</label>
                        <textarea class="form-control" id="alipayPublicKey" name="alipayPublicKey"
                                  rows="3">${settings.alipayPublicKey}</textarea>
                    </div>

                    <div class="form-group">
                        <label for="alipayPrivateKey">支付宝私钥</label>
                        <textarea class="form-control" id="alipayPrivateKey" name="alipayPrivateKey"
                                  rows="3">${settings.alipayPrivateKey}</textarea>
                    </div>

                    <div class="form-group">
                        <label for="wechatAppId">微信AppID</label>
                        <input type="text" class="form-control" id="wechatAppId" name="wechatAppId"
                               value="${settings.wechatAppId}">
                    </div>

                    <div class="form-group">
                        <label for="wechatMchId">微信商户号</label>
                        <input type="text" class="form-control" id="wechatMchId" name="wechatMchId"
                               value="${settings.wechatMchId}">
                    </div>

                    <div class="form-group">
                        <label for="wechatApiKey">微信API密钥</label>
                        <input type="password" class="form-control" id="wechatApiKey" name="wechatApiKey"
                               value="${settings.wechatApiKey}">
                    </div>

                    <div class="form-actions">
                        <button type="reset" class="btn btn-outline">
                            <i class="fas fa-undo"></i> 重置
                        </button>
                        <button type="submit" class="btn btn-primary">
                            <i class="fas fa-key"></i> 保存密钥
                        </button>
                    </div>
                </form>
            </div>
        </div>

        <!-- 系统参数设置 -->
        <div id="system-settings" class="tab-content">
            <div class="settings-card">
                <h3><i class="fas fa-cog"></i> 系统基本参数</h3>
                <form action="/admin/settings/system" method="post">
                    <div class="form-group">
                        <label for="systemName">系统名称</label>
                        <input type="text" class="form-control" id="systemName" name="systemName"
                               value="${settings.systemName}" required>
                    </div>

                    <div class="form-row">
                        <div class="form-group">
                            <label for="adminEmail">管理员邮箱</label>
                            <input type="email" class="form-control" id="adminEmail" name="adminEmail"
                                   value="${settings.adminEmail}" required>
                        </div>
                        <div class="form-group">
                            <label for="customerServicePhone">客服电话</label>
                            <input type="tel" class="form-control" id="customerServicePhone" name="customerServicePhone"
                                   value="${settings.customerServicePhone}" required>
                        </div>
                    </div>

                    <div class="form-row">
                        <div class="form-group">
                            <label for="systemLogo">系统Logo URL</label>
                            <input type="url" class="form-control" id="systemLogo" name="systemLogo"
                                   value="${settings.systemLogo}">
                            <small class="text-muted">建议尺寸: 200x60像素</small>
                        </div>
                        <div class="form-group">
                            <label for="favicon">网站图标 (Favicon)</label>
                            <input type="url" class="form-control" id="favicon" name="favicon"
                                   value="${settings.favicon}">
                            <small class="text-muted">建议尺寸: 32x32像素</small>
                        </div>
                    </div>

                    <div class="form-actions">
                        <button type="reset" class="btn btn-outline">
                            <i class="fas fa-undo"></i> 重置
                        </button>
                        <button type="submit" class="btn btn-primary">
                            <i class="fas fa-save"></i> 保存设置
                        </button>
                    </div>
                </form>
            </div>

            <div class="settings-card">
                <h3><i class="fas fa-bell"></i> 通知设置</h3>
                <form action="/admin/settings/notification" method="post">
                    <div class="form-group">
                        <label>启用通知方式</label>
                        <div class="radio-group">
                            <div class="radio-option">
                                <input type="checkbox" id="enableSms" name="enableSms"
                                ${settings.enableSms ? 'checked' : ''}>
                                <label for="enableSms"><i class="fas fa-sms" style="color: #2196F3;"></i> 短信通知</label>
                            </div>
                            <div class="radio-option">
                                <input type="checkbox" id="enableEmail" name="enableEmail"
                                ${settings.enableEmail ? 'checked' : ''}>
                                <label for="enableEmail"><i class="fas fa-envelope" style="color: #FF5722;"></i> 邮件通知</label>
                            </div>
                            <div class="radio-option">
                                <input type="checkbox" id="enableAppPush" name="enableAppPush"
                                ${settings.enableAppPush ? 'checked' : ''}>
                                <label for="enableAppPush"><i class="fas fa-mobile-alt" style="color: #673AB7;"></i> APP推送</label>
                            </div>
                        </div>
                    </div>

                    <div class="form-row">
                        <div class="form-group">
                            <label for="smsApiKey">短信API密钥</label>
                            <input type="password" class="form-control" id="smsApiKey" name="smsApiKey"
                                   value="${settings.smsApiKey}">
                        </div>
                        <div class="form-group">
                            <label for="emailSmtpHost">邮件SMTP服务器</label>
                            <input type="text" class="form-control" id="emailSmtpHost" name="emailSmtpHost"
                                   value="${settings.emailSmtpHost}">
                        </div>
                    </div>

                    <div class="form-row">
                        <div class="form-group">
                            <label for="emailSmtpPort">SMTP端口</label>
                            <input type="number" class="form-control" id="emailSmtpPort" name="emailSmtpPort"
                                   value="${settings.emailSmtpPort}">
                        </div>
                        <div class="form-group">
                            <label for="emailUsername">邮件用户名</label>
                            <input type="text" class="form-control" id="emailUsername" name="emailUsername"
                                   value="${settings.emailUsername}">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="emailPassword">邮件密码</label>
                        <input type="password" class="form-control" id="emailPassword" name="emailPassword"
                               value="${settings.emailPassword}">
                    </div>

                    <div class="form-actions">
                        <button type="button" class="btn btn-outline" onclick="testNotification()">
                            <i class="fas fa-paper-plane"></i> 测试通知
                        </button>
                        <button type="submit" class="btn btn-primary">
                            <i class="fas fa-save"></i> 保存设置
                        </button>
                    </div>
                </form>
            </div>
        </div>

        <!-- 用户权限设置 -->
        <div id="user-permissions" class="tab-content">
            <div class="settings-card">
                <h3><i class="fas fa-user-shield"></i> 角色权限设置</h3>
                <form action="/admin/settings/permissions" method="post">
                    <div class="form-group">
                        <label>普通用户权限</label>
                        <div class="radio-group">
                            <div class="radio-option">
                                <input type="checkbox" id="userCharge" name="userCharge"
                                ${permissions.userCharge ? 'checked' : ''}>
                                <label for="userCharge"><i class="fas fa-bolt"></i> 充电权限</label>
                            </div>
                            <div class="radio-option">
                                <input type="checkbox" id="userRecharge" name="userRecharge"
                                ${permissions.userRecharge ? 'checked' : ''}>
                                <label for="userRecharge"><i class="fas fa-dollar-sign"></i> 充值权限</label>
                            </div>
                            <div class="radio-option">
                                <input type="checkbox" id="userReport" name="userReport"
                                ${permissions.userReport ? 'checked' : ''}>
                                <label for="userReport"><i class="fas fa-exclamation-triangle"></i> 故障报告</label>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label>管理员权限</label>
                        <div class="radio-group">
                            <div class="radio-option">
                                <input type="checkbox" id="adminUserMgmt" name="adminUserMgmt"
                                ${permissions.adminUserMgmt ? 'checked' : ''}>
                                <label for="adminUserMgmt"><i class="fas fa-users"></i> 用户管理</label>
                            </div>
                            <div class="radio-option">
                                <input type="checkbox" id="adminPileMgmt" name="adminPileMgmt"
                                ${permissions.adminPileMgmt ? 'checked' : ''}>
                                <label for="adminPileMgmt"><i class="fas fa-charging-station"></i> 充电桩管理</label>
                            </div>
                            <div class="radio-option">
                                <input type="checkbox" id="adminReportMgmt" name="adminReportMgmt"
                                ${permissions.adminReportMgmt ? 'checked' : ''}>
                                <label for="adminReportMgmt"><i class="fas fa-clipboard-list"></i> 报告管理</label>
                            </div>
                            <div class="radio-option">
                                <input type="checkbox" id="adminSettings" name="adminSettings"
                                ${permissions.adminSettings ? 'checked' : ''}>
                                <label for="adminSettings"><i class="fas fa-cog"></i> 系统设置</label>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label>超级管理员权限</label>
                        <div class="radio-group">
                            <div class="radio-option">
                                <input type="checkbox" id="superAdminAll" name="superAdminAll"
                                ${permissions.superAdminAll ? 'checked' : ''} disabled>
                                <label for="superAdminAll"><i class="fas fa-star"></i> 所有权限</label>
                            </div>
                        </div>
                    </div>

                    <div class="form-actions">
                        <button type="reset" class="btn btn-outline">
                            <i class="fas fa-undo"></i> 重置
                        </button>
                        <button type="submit" class="btn btn-primary">
                            <i class="fas fa-save"></i> 保存权限
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script>
    // 标签页切换功能
    function openTab(evt, tabName) {
        const tabContents = document.getElementsByClassName("tab-content");
        for (let i = 0; i < tabContents.length; i++) {
            tabContents[i].classList.remove("active");
        }

        const tabButtons = document.getElementsByClassName("tab-button");
        for (let i = 0; i < tabButtons.length; i++) {
            tabButtons[i].classList.remove("active");
        }

        document.getElementById(tabName).classList.add("active");
        evt.currentTarget.classList.add("active");
    }

    // 更新地图中心坐标
    function updateMapCenter() {
        const lat = document.getElementById("latitude").value;
        const lng = document.getElementById("longitude").value;

        // 这里应该调用地图API更新中心点
        const mapPreview = document.getElementById("mapPreview");
        mapPreview.innerHTML = `
            <i class="fas fa-check-circle" style="color: #4CAF50; font-size: 24px; margin-right: 10px;"></i>
            <span>地图中心已更新为: ${lat}, ${lng}</span>
        `;

        // 3秒后恢复原状
        setTimeout(() => {
            mapPreview.innerHTML = `
                <i class="fas fa-map-marked-alt" style="font-size: 24px; margin-right: 10px;"></i>
                <span>地图预览区域</span>
            `;
        }, 3000);
    }

    // 测试通知功能
    function testNotification() {
        const btn = event.target;
        const originalText = btn.innerHTML;

        btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> 发送中...';
        btn.disabled = true;

        // 模拟API调用延迟
        setTimeout(() => {
            alert("测试通知已发送！请检查您的邮箱、手机或APP");
            btn.innerHTML = originalText;
            btn.disabled = false;
        }, 1500);
    }

    // 显示添加角色模态框
    function showAddRoleModal() {
        alert("添加角色功能将在后续版本实现");
    }
</script>
</body>
</html>